from cProfile import label
from time import sleep
from PyQt5 import uic
from PyQt5.QtWidgets import QApplication, QMessageBox,QAction
from PyQt5.QtCore import *
from PyQt5.QtGui import *
import sys

from threading import Thread,Lock

#这里是将封装好的类导入本文件




class ui_Menu():

    def __init__(self):
        # 从文件中加载UI定义

        # 从 UI 定义中动态 创建一个相应的窗口对象
        # 注意：里面的控件对象也成为窗口对象的属性了
        # 比如 self.ui.button , self.ui.textEdit
        self.ui = uic.loadUi("ui/start_menu.ui")
        self.ui.setWindowTitle("开始界面")
        self.ui.read_file.clicked.connect(self.Read_file)
        self.ui.train.clicked.connect(self.Train)
        self.ui.generator.clicked.connect(self.Generator)
        self.ui.quit.clicked.connect(self.back)



    #数据读取
    def Read_file(self):
        '''
        进行图片的读取
        :return:
        '''

        stats = ui_1()
        stats.ui.show()
        #self.ui.close()
        # app.exec_()
    #开始训练
    def Train(self):
        '''
        调用lora进行训练
        :return:
        '''
        stats = ui_2()
        stats.ui.show()
        #self.ui.close()
        app.exec_()
        # 关闭线程并退出

    def Generator(self):
        '''
        生成图片
        :return:
        '''

    def back(self):
        print("开始关闭ui")
        self.ui.close()

if __name__ == '__main__':

    app = QApplication([])
    stats = ui_Menu()
    stats.ui.show()
    app.exec_()